/**
 * @file:          Config_Encoder.c
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2023.06.12
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.06.12,12:43:05
 */
/* Include Files **************************************************************/
#include "ConfigOption.h"
#include "string.h"

/* Function Declare ***********************************************************/

/* Global Variable Define *****************************************************/
void Config_encoder_MT6816_14bit(MT68xx *self);
MT68xx encoder_MT6816_14bit = {.ConfigParam = Config_encoder_MT6816_14bit};
void Config_encoder_MT6816_14bit(MT68xx *self)
{
    memset(self, 0, sizeof(MT68xx));
    self->ConfigParam = Config_encoder_MT6816_14bit;
    self->Init = MT6816_14bit_Init;

    self->param_direction = 1;
    self->parma_encoder_bit = 14;
    self->param_encoder_max_pulse = 16384L;
    // self->param_single_turn_mode = TRUE;

    /* fake_encoder setting */
    self->param_fake_encoder_en = 0;
    self->param_fake_encoder_step = -1;

    // self->calibrator.Init = EncoderCalibrator_Init;
    // self->calibrator.param_en = 0;
    // self->calibrator.param_encoder_max_pulse = self->param_encoder_max_pulse;
    // FourierCoeff coeffs[] = {
    //     // {0.5, 10, BM_PI/2},
    //     // {0.3, 20, BM_PI},
    //     {-3.0006748628597377e-05, 1.0, 0.20087204313224996},
    //     {0.18120840795593338, 2.0, 0.0003431900665639645},
    //     {-3.235294559560483e-05, 3.0, 0.5019830862618393},
    //     {0.1205756452452604, 4.0, 1.5717598562068713},
    //     {-1.8411700283275636e-05, 5.0, 0.3368896130150817},
    //     {-0.01874527379581488, 6.0, 0.001982743689211271},
    //     {-2.2316743025332255e-05, 7.0, 1.5205582923848333},
    //     {-0.016047385644402945, 8.0, 1.5717912645306167},

    // };
    // memcpy(self->calibrator.coeffs, coeffs, sizeof(coeffs));
}


void Config_encoder_MT6826_15bit(MT68xx *self);
MT68xx encoder_MT6826_15bit = {.ConfigParam = Config_encoder_MT6826_15bit};
void Config_encoder_MT6826_15bit(MT68xx *self)
{
    memset(self, 0, sizeof(MT68xx));
    self->ConfigParam = Config_encoder_MT6826_15bit;
    self->Init = MT6826_15bit_Init;

    self->param_direction = 1;
    self->parma_encoder_bit = 15;
    self->param_encoder_max_pulse = 32768;//65536;//2097152L;
    // self->param_single_turn_mode = TRUE;

    /* fake_encoder setting */
    self->param_fake_encoder_en = 0;
    self->param_fake_encoder_step = -1;

    // self->calibrator.Init = EncoderCalibrator_Init;
    // self->calibrator.param_en = 0;
    // self->calibrator.param_encoder_max_pulse = self->param_encoder_max_pulse;
    // FourierCoeff coeffs[] = {
    //     // {0.5, 10, BM_PI/2},
    //     // {0.3, 20, BM_PI},
    //     {-3.0006748628597377e-05, 1.0, 0.20087204313224996},
    //     {0.18120840795593338, 2.0, 0.0003431900665639645},
    //     {-3.235294559560483e-05, 3.0, 0.5019830862618393},
    //     {0.1205756452452604, 4.0, 1.5717598562068713},
    //     {-1.8411700283275636e-05, 5.0, 0.3368896130150817},
    //     {-0.01874527379581488, 6.0, 0.001982743689211271},
    //     {-2.2316743025332255e-05, 7.0, 1.5205582923848333},
    //     {-0.016047385644402945, 8.0, 1.5717912645306167},

    // };
    // memcpy(self->calibrator.coeffs, coeffs, sizeof(coeffs));
}

void Config_encoder_MT6835_21bit(MT68xx *self);
MT68xx encoder_MT6835_21bit = {.ConfigParam = Config_encoder_MT6835_21bit};
void Config_encoder_MT6835_21bit(MT68xx *self)
{
    memset(self, 0, sizeof(MT68xx));
    self->ConfigParam = Config_encoder_MT6835_21bit;
    self->Init = MT6835_21bit_Init;

    self->param_direction = 1;
    self->parma_encoder_bit = 16;
    self->param_encoder_max_pulse = 65536;//2097152L;
    // self->param_single_turn_mode = TRUE;

    /* fake_encoder setting */
    self->param_fake_encoder_en = 0;
    self->param_fake_encoder_step = -1;

    // self->calibrator.Init = EncoderCalibrator_Init;
    // self->calibrator.param_en = 0;
    // self->calibrator.param_encoder_max_pulse = self->param_encoder_max_pulse;
    // FourierCoeff coeffs[] = {
    //     // {0.5, 10, BM_PI/2},
    //     // {0.3, 20, BM_PI},
    //     {-3.0006748628597377e-05, 1.0, 0.20087204313224996},
    //     {0.18120840795593338, 2.0, 0.0003431900665639645},
    //     {-3.235294559560483e-05, 3.0, 0.5019830862618393},
    //     {0.1205756452452604, 4.0, 1.5717598562068713},
    //     {-1.8411700283275636e-05, 5.0, 0.3368896130150817},
    //     {-0.01874527379581488, 6.0, 0.001982743689211271},
    //     {-2.2316743025332255e-05, 7.0, 1.5205582923848333},
    //     {-0.016047385644402945, 8.0, 1.5717912645306167},

    // };
    // memcpy(self->calibrator.coeffs, coeffs, sizeof(coeffs));
}